# -*- coding: utf-8 -*-
# @Time    : 2024/5/19 9:25
# @Author  : Alvin
# @File    : redis_service.py
import redis
import json
import os
GLOBAL_HOST = os.getenv('GLOBAL_HOST', 'localhost')

redis_client = redis.StrictRedis(host=GLOBAL_HOST, port=6379, db=4)
def get_progress(job_id):
    if job_id:
        result = redis_client.get(job_id)
        if result:
            result = json.loads(result)
        return result
    return None
def set_progress(job_id, value):
    value = json.dumps(value)
    redis_client.set(job_id,value)